global using Microsoft.EntityFrameworkCore;

using WXWorkSvc.Common.Models;

namespace WXWorkSvc.Private.Pages.Account;

public class UserInfoModel : PageModel
{
    private readonly WXDbContext db;
    public TPrivateUser Item { get; set; } = default!;
    public UserInfoModel(WXDbContext dbc)
    {
        db = dbc;
    }
    public async Task OnGetAsync([FromServices] WXWorkConfig config, [FromServices]IRole r)
    {
        Item = await db.PrivateUsers.Where(ii => ii.AgentId == config.AgentId && ii.UserId == User.Identity!.Name).FirstAsync();
        Item.RoleNames = r.GetRoleNames(Item.Roles);

    }


}
